<?php
namespace App\Http\Forms;

use App\Library\OSS;
use Kris\LaravelFormBuilder\Form;

class CrowdGoodForm extends Form
{
    public function buildForm()
    {
        $key = "video"."/".uniqid().random_int(10, 99);
        $this
//            ->add('shop_id', 'select', [
//                'label' => "店铺",
//                'rules' => 'required|string',
//                'choices' => $this->getData('shop'),
//            ])
            ->add('name', 'text', [
                'label' => "礼包名称",
                'rules' => 'required|string',
            ])
            ->add('cover', 'image_list', [
                'label' => "展示图",
                'rules' => 'required|array',
                'type' => 'crowd_cover',
            ])
            ->add('video', "video", [
                'label' => "上传视频",
                'rules' => 'nullable',
                'async' => true,
                'config' => OSS::instance('video')->getSign($key),
            ])
            ->add('display_price', 'text', [
                'label' => "划线价",
                'rules' => 'required|numeric|min:0|max:9999999',
            ])
            ->add('price', 'text', [
                'label' => "价格",
                'rules' => "required|numeric|min:0|max:9999999",
            ])
            ->add('description', 'textarea', [
                'attr' => ['id' => 'editor'],
                'label' => "介绍",
                'rules' => 'required|string',
            ])
            ->add('submit', 'submit', [
                'attr' => ['class' => "form-control btn btn-success"],
                'label' => '保存',
            ]);
    }
}
